//
//  LoginViewController.m
//  ForeverLove
//
//  Created by lanou3g on 15/11/17.
//  Copyright © 2015年 文萱竹. All rights reserved.
//

#import "LoginViewController.h"
#import <AVOSCloud/AVOSCloud.h>

@interface LoginViewController ()

@property (weak, nonatomic) IBOutlet UITextField *userName;
@property (weak, nonatomic) IBOutlet UITextField *pwd;

- (IBAction)loginAction:(UIButton *)sender;

@end

@implementation LoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

// 登陆事件
- (IBAction)loginAction:(UIButton *)sender
{
    
    [AVUser logInWithUsernameInBackground:self.userName.text password:self.pwd.text block:^(AVUser *user, NSError *error) {
        if (user) {
            NSLog(@"登陆成功");
            NSLog(@"username = %@", user.username);
             // 登陆成功就跳转到tabBarController
            UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
            UITabBarController *tabBarC = [board instantiateViewControllerWithIdentifier:@"tabBarID"];
            UIWindow *window = [UIApplication sharedApplication].keyWindow;
            window.rootViewController = tabBarC;
        } else {
            NSLog(@"登陆失败:%@", error.userInfo);
        }
    }];
    
}




/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/



@end
